# author:高金磊
# datetime:2021/11/8 10:13
import time

import pytest

from Statics.Setting import Interface_access_speed_max

from Tools.check_net import isNetChainOK

from Tools.myPrint import *


@pytest.fixture(scope='function')
def DelayaccessFixture():
    pass
    yield
    time.sleep(1 / Interface_access_speed_max)


@pytest.fixture(scope='session',autouse=True)
def CheckEnvFixture():
    while 1:
        flag = True
        if isNetChainOK():
            print("网络连接正常")
        else:
            flag = False
            print("网络连接异常")
        if Interface_access_speed_max<200:
            print("接口调用速度为%s符合要求"%(Interface_access_speed_max))
        else:
            flag=False
            print("接口调用速度为%s不符合要求" % (Interface_access_speed_max))


        if not flag:
            print("环境检查未通过稍后将重试")
            time.sleep(10)
        else:
            print("环境检查通过!")
            break
    yield
    pass
